package com.mes.warehouse.controller;

import com.mes.common.pojo.MESResult;
import com.mes.pojo.warehouse.Warehouse;
import com.mes.warehouse.server.WarehouseServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 张喆
 * @Company
 * @Description
 * @Time 2024/10/24 14:58
 */
@RestController
@CrossOrigin
@RequestMapping("/warehouse")
public class WarehouseController {
    @Autowired
    private WarehouseServer warehouseServer;

    @GetMapping("/list")
    public MESResult getList(Warehouse warehouse, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer limit) {
        return warehouseServer.selectAll(warehouse, pageNum, limit);
    }
    @GetMapping("/updateInfo")
    public MESResult getUpdateInfo(String warehouseId){
        return warehouseServer.selectById(warehouseId);
    }
    @DeleteMapping("/delete")
    public MESResult delete(String warehouseId){
        return warehouseServer.deleteWarehouse(warehouseId);
    }
    @PutMapping("/update")
    public MESResult update(@RequestBody Warehouse warehouse){
        return warehouseServer.updateWarehouse(warehouse);
    }
    @PostMapping("/insert")
    public MESResult insert(@RequestBody Warehouse warehouse){
        return warehouseServer.insertWarehouse(warehouse);
    }

}
